package com.matrix.java.chap_06;

import java.util.Scanner;

/*
    MyTriangle 类
 */
public class Ex6_19 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("a,b,c: ");
        double a = input.nextDouble();
        double b = input.nextDouble();
        double c = input.nextDouble();
        input.close();
        if (isValid(a, b, c)) {
            System.out.println("输入有效,面积: " + area(a, b, c));
        } else {
            System.out.println("输入无效");
        }
    }

    private static double area(double side1, double side2, double side3) {
        double s = (side1 + side2 + side3) / 2;
        return Math.pow(s * (s - side1) * (s - side2) * (s - side3), 0.5);
    }

    private static boolean isValid(double side1, double side2, double side3) {
        boolean isValid = false;
        if ((side1 + side2) > side3 && (side1 + side3) > side2 && (side3 + side2) > side1) {
            isValid = true;
        }
        return isValid;
    }
}
